import 'package:flutter/material.dart';
import 'package:flutter_app/config/colorconfig.dart';

import '../errorPage.dart';
import 'settingsPate/aboutPage.dart';

//设置
Widget SettingListBottom(context, index, {navigateTo}) {
  return Container(
    child: RaisedButton(
      onPressed: () {
        if (navigateTo == null)
          Navigator.push(
              context, MaterialPageRoute(builder: (context) => errorPage(0)));
        else
          Navigator.push(
              context, MaterialPageRoute(builder: (context) => navigateTo));
      },
      color: Colors.white,
      child: ListTile(
        title: Text(index),
        trailing: Icon(
          Icons.navigate_next,
          color: Colors.lightGreen,
        ),
      ),
    ),
    decoration: BoxDecoration(
      border: Border.all(color: Color.fromRGBO(142, 203, 185, 1)),
    ),
  );
}

class SettingPage extends StatefulWidget {
  SettingPage({Key key}) : super(key: key);
  @override
  _SettingPageState createState() => _SettingPageState();
}

class _SettingPageState extends State<SettingPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        iconTheme: IconThemeData(
          color: Colors.grey,
        ),
        centerTitle: true,
        title: Text(
          "设置",
          style: TextStyle(color: Colors.black),
        ),
        elevation: 0,
        backgroundColor: Colors.white,
      ),
      body: Column(
        children: <Widget>[
          Divider(color: defaultgreen, thickness: 15),
          SettingListBottom(context, "账号管理"),
          SettingListBottom(context, "账号与安全"),
          Divider(color: defaultgreen, thickness: 15),
          SettingListBottom(context, "推送通知设置"),
          SettingListBottom(context, "屏蔽设置"),
          SettingListBottom(context, "隐私设置"),
          SettingListBottom(context, "通用设置"),
          Divider(color: defaultgreen, thickness: 15),
          SettingListBottom(context, "青少年模式"),
          SettingListBottom(context, "夜览模式"),
          Divider(color: defaultgreen, thickness: 15),
          SettingListBottom(context, "帮助与反馈"),
          SettingListBottom(context, "关于Gonovo", navigateTo: aboutPage()),
          RaisedButton(
            onPressed: () {},
            color: Color.fromRGBO(142, 203, 185, 1),
            child: Center(
              child: Text("退出登录"),
            ),
          ),
        ],
      ),
    );
  }
}
